using System;
using System.ServiceModel;

namespace Pegasus.ServiceModel
{
	/// <summary>
	/// This defines the service contract for broadcast operation (when a code talks to the reset of the mesh).
	/// </summary>
	[ServiceContract( Name = "IBroadcast", Namespace = "http://ServiceModel.Pegasus-Tech.Net", CallbackContract = typeof( IBroadcast ) )]
	internal interface IBroadcast 
	{
		/// <summary>
		/// Sends the message.
		/// </summary>
		/// <param name="sender">The name of the node that sent the message.</param>
		/// <param name="message">The message.</param>
		[OperationContract( IsOneWay = true )]
		void SendBroadcastMessage( string sender, object message );

		/// <summary>
		/// Notification that a node has entered the mesh.
		/// </summary>
		/// <param name="nodeInfo">The node info.</param>
		[OperationContract( IsOneWay = true )]
		void SendNodeEnter( NodeData nodeInfo );

		/// <summary>
		/// Notification that a node has exited the mesh.
		/// </summary>
		/// <param name="nodeInfo">The node info.</param>
		[OperationContract( IsOneWay = true )]
		void SendNodeExit( NodeData nodeInfo );

		/// <summary>
		/// Sends a request to the group to see if anyone has the node 
		/// info for the given node.
		/// </summary>
		/// <param name="sender">The name of the node that sent the message.</param>
		/// <param name="nodeName">Name of the node that they are looking for.</param>
		[OperationContract( IsOneWay = true )]
		void SendNodeWhoIs( string sender, string nodeName );

		/// <summary>
		/// Sends the node fault message to tell the other nodes that 
		/// this guy has a problem.
		/// </summary>
		/// <param name="sender">The name of the node that sent the message.</param>
		/// <param name="nodeInfo">The node info.</param>
		[OperationContract( IsOneWay = true )]
		void SendNodeFault( string sender, NodeData nodeInfo );

		/// <summary>
		/// Sends the hartbeat message from a given node.
		/// </summary>
		/// <param name="sender">The name of the node that sent the message.</param>
		[OperationContract( IsOneWay = true )]
		void SendHartbeat( string sender );
	}
}
